package com.huaxin.device.dto.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.huaxin.hxenum.validation.ValidDataQuality;
import com.huaxin.hxenum.validation.ValidDataType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
public class CollectedDataRecordCreateReqDTO {

    @Schema(description = "采集设备ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "collector-001")
    @NotBlank(message = "采集设备ID不能为空")
    private String collectorId;

    @Schema(description = "设备序列号", example = "SN123456789")
    private String deviceSerial;

    @Schema(description = "采集设备名称冗余", example = "采集器A1")
    private String collectorName;

    @Schema(description = "被采集电力设备ID", example = "equip-001")
    private String equipmentId;

    @Schema(description = "配电房ID", example = "room-001")
    private String roomId;

    @Schema(description = "变电箱ID", example = "cabinet-001")
    private String cabinetId;

    @Schema(description = "电井ID", example = "well-001")
    private String wellId;

    @Schema(description = "指标编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "100001")
    @NotBlank(message = "指标编码不能为空")
    private String metricCode;

    @Schema(description = "数据项名称", example = "A相电压")
    private String dataName;

    @Schema(description = "单位", example = "V")
    private String unit;

    @Schema(description = "字符串值", example = "ON")
    private String valueString;

    @Schema(description = "数值型值", example = "220.5000")
    private BigDecimal valueNumber;

    @Schema(description = "值类型：number, string", requiredMode = Schema.RequiredMode.REQUIRED, example = "number")
    @NotNull(message = "值类型不能为空")
    @ValidDataType
    private String valueType;

    @Schema(description = "采集时间（ISO8601）", requiredMode = Schema.RequiredMode.REQUIRED, example = "2025-04-05 10:30:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "采集时间不能为空")
    private LocalDateTime collectedAt;

    @Schema(description = "接收时间", example = "2025-04-05 10:30:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime receivedAt;

    @Schema(description = "数据质量：normal, over_limit, offline, abnormal", example = "normal")
    @ValidDataQuality
    private String quality;
}